﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace QunYing.Web.market
{
    public partial class mycollect : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Repeater rp = ((Repeater)Master.FindControl("NavRepeater"));
                rp.DataSource = NavData();
                rp.DataBind();
            }
        }
        /// <summary>
        /// 快捷导航数据
        /// </summary>
        private DataTable NavData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("url");
            dt.Rows.Add("我的收藏", "");
            return dt;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            DataTable dt = new BLL.Collect().GetCollects(((ArrayList)Session["userInfo"])[0].ToString());
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        protected void btnDel_Click(object sender, EventArgs e)
        {
            int index = Convert.ToInt32((sender as LinkButton).CommandArgument);
            string id = this.GridView1.DataKeys[index].Values[0].ToString();//商品ID
            if (new BLL.Collect().Delete(Convert.ToInt32(id)))
            {
                BindData();
            }
            else
            {
                MessageBox.Show(this,"取消失败！");
            }

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindData();
        }
    }
}
